﻿using WebAPI.Filters;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using wt.wine.Application.Common.Models;
using wt.wine.Application.ManageDevicetable;
using wt.wine.Application.ManageDevicetable.Command;
using wt.wine.Application.ManageDevicetable.Queries;

namespace WebAPI.Controllers.V1
{
    [ApiController]
    [Route("[controller]/[action]")]
    [LoginFilter]
    public class ManageDevicetableController : ApiControllerBase
    {

        /// <summary>
        /// 通过登录id获取设备名称
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("AddOrderInfo,ManageOrderTable")]
        [HttpPost]
        public async Task<Json<List<GetDevicetableNameDTO>>> GetDevicetableNameList([FromBody] GetDevicetableNameQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 获取出酒状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [PermissioneFilter("AddOrderInfo,ptGetUserList,GetUserList")]
        public async Task<Json<List<GetDevicetableNameStateusDTO>>> GetDevicetableNameStateus([FromBody] GetDevicetableNameStateusQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 新增设备
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageDevicetable")]
        [HttpPost]
        public async Task<Json<string>> AddDevice([FromBody] AddDeviceCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【经销商】编辑设备
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageDevicetable")]
        [HttpPost]
        public async Task<Json<string>> EditAddDevice([FromBody] EditAddDeviceCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【经销商】设备列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageDevicetable,ManageOrderTable")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetDevicetableListByUserIdDTO>>> GetDevicetableListByUserId([FromBody] GetDevicetableListByUserIdQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】设备加酒：获取商品
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("AddDeviceRecord,GetDevicerecordList")]
        [HttpPost]
        public async Task<Json<GetDeviceNameByAddWineDTO>> GetDeviceNameByAddWineId([FromBody] GetDeviceNameByAddWineIdQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】设备加酒：获取商品列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("AddDeviceRecord,GetDevicerecordList")]
        [HttpPost]
        public async Task<Json<List<GetDeviceNameByAddWineDTO>>> GetDeviceNameByAddWine([FromBody] GetDeviceNameByAddWineQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】获取修改的设备列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageDevicetable")]
        [HttpPost]
        public async Task<Json<GetDeviceByIdDTO>> GetDeviceById([FromBody] GetDeviceByIdQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】缺酒补货提醒
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetDeviceLessWine")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetDeviceLessWineDTO>>> GetDeviceLessWine([FromBody] GetDeviceLessWineQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】添加员工 获取设备信息
        /// </summary>
        /// <returns></returns>
        [PermissioneFilter("ManageDevicetable")]
        [HttpPost]
        public async Task<Json<List<GetDeviceByAddUserDTO>>> GetDeviceByAddUser()
        {
            GetDeviceByAddUserQueries query = new GetDeviceByAddUserQueries();
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【平台】设备列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetManageDeviceList")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetManageDeviceListDTO>>> GetManageDeviceList([FromBody] GetManageDeviceListQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【平台】新增设备
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("AddManageDevice")]
        [HttpPost]
        public async Task<Json<string>> AddManageDevice([FromBody] AddManageDeviceCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【平台】修改设备
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("AddManageDevice")]
        [HttpPost]
        public async Task<Json<string>> EditManageDevice([FromBody] EditManageDeviceCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【平台】设备详情
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetManageDeviceList")]
        [HttpPost]
        public async Task<Json<GetDeviceModelByIdDTO>> GetDeviceModelById([FromBody] GetDeviceModelByIdQueries query)
        {
            return await Mediator.Send(query);
        }
    }
}
